using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using MCromwell.StaffIntranet.Security;
using System.Web.SessionState;

namespace MCromwell.StaffIntranet.UI
{
    public class SessionCheckingPageAuthenticationModule : PageAuthenticationModule, IRequiresSessionState
    {
        private LoginSessionChecker loginSessionChecker = null;

        public SessionCheckingPageAuthenticationModule()
        {
            loginSessionChecker = new LoginSessionChecker();
        }
        
        protected override bool AllowAccess()
        {
            Guid sessionId = LoginManager.RetrieveCurrentSessionIdentifer();
            return loginSessionChecker.CheckUsing(sessionId);
        }
    }
}
